package com.ruoyi.appService.testresult.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.appService.mentalTestResult.huolandResult.domain.ZTestHuolandTestresult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appService.testresult.domain.ZCollegeStudentsTestresult;
import com.ruoyi.appService.testresult.service.IZCollegeStudentsTestresultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大学生心理测试结果Controller
 * 
 * @author yuqihe
 * @date 2025-05-17
 */
@RestController
@RequestMapping("/mentalTest/testresult")
public class ZCollegeStudentsTestresultController extends BaseController
{
    @Autowired
    private IZCollegeStudentsTestresultService zCollegeStudentsTestresultService;

    /**
     * 查询大学生心理测试结果列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:testresult:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZCollegeStudentsTestresult zCollegeStudentsTestresult)
    {
        startPage();
        List<ZCollegeStudentsTestresult> list = zCollegeStudentsTestresultService.selectZCollegeStudentsTestresultList(zCollegeStudentsTestresult);
        return getDataTable(list);
    }

    /**
     * 导出大学生心理测试结果列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:testresult:export')")
    @Log(title = "大学生心理测试结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZCollegeStudentsTestresult zCollegeStudentsTestresult)
    {
        List<ZCollegeStudentsTestresult> list = zCollegeStudentsTestresultService.selectZCollegeStudentsTestresultList(zCollegeStudentsTestresult);
        ExcelUtil<ZCollegeStudentsTestresult> util = new ExcelUtil<ZCollegeStudentsTestresult>(ZCollegeStudentsTestresult.class);
        util.exportExcel(response, list, "大学生心理测试结果数据");
    }

    /**
     * 获取大学生心理测试结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:testresult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zCollegeStudentsTestresultService.selectZCollegeStudentsTestresultById(id));
    }

    /**
     * 新增大学生心理测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:testresult:add')")
    @Log(title = "大学生心理测试结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZCollegeStudentsTestresult zCollegeStudentsTestresult)
    {
        return toAjax(zCollegeStudentsTestresultService.insertZCollegeStudentsTestresult(zCollegeStudentsTestresult));
    }

    /**
     * 修改大学生心理测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:testresult:edit')")
    @Log(title = "大学生心理测试结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZCollegeStudentsTestresult zCollegeStudentsTestresult)
    {
        return toAjax(zCollegeStudentsTestresultService.updateZCollegeStudentsTestresult(zCollegeStudentsTestresult));
    }

    /**
     * 删除大学生心理测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:testresult:remove')")
    @Log(title = "大学生心理测试结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zCollegeStudentsTestresultService.deleteZCollegeStudentsTestresultByIds(ids));
    }

    // 给小程序端提供的新增或修改测试结果
    @PostMapping("addOrUpdate")
    public AjaxResult addOrupdateTestResult(@RequestBody ZCollegeStudentsTestresult zCollegeStudentsTestresult, HttpServletRequest request)
    {
        zCollegeStudentsTestresultService.addOrupdateTestResult(zCollegeStudentsTestresult,request);
        return AjaxResult.success();
    }

    //    查询测试结果根据用户id
    @PostMapping("selectTestResult")
    public AjaxResult selectTestResult( HttpServletRequest request)
    {
        return  zCollegeStudentsTestresultService.selectTestResult(request);
    }


}
